package com.mvc.controller;


import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
@RequestMapping("/user")
public class UserController {
    //localhost:8080/user/t1?name=xxx
    @GetMapping("/t1")
    public String test1(@RequestParam("username") String name, Model model){
        //1.接收前端参数
        System.out.println("接收到前端的参数为："+name);

        //2.讲返回的结果传递给前端:Model
        model.addAttribute("msg",name);
        //3.试图跳转
        return "hello";
    }

    //前端接收一个对象，id，name,age
    public String test2(){
// TODO: 2021/8/27  

        return "hello";

    }
}
